package com.example.viewpagerandlistview.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

import com.example.viewpagerandlistview.R;

public class ListViewAdapter extends BaseAdapter {
    Context context;
    String[] strings;

    public ListViewAdapter(Context context, String[] strings) {
        this.context = context;
        this.strings = strings;
    }

    @Override
    public int getCount() {
        return strings.length;
    }

    @Override
    public Object getItem(int position) {
        return strings[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (convertView == null ){
            convertView = View.inflate(context, R.layout.listview,null);
        }
        TextView textView = convertView.findViewById(R.id.textview);
        textView.setText(strings[position]);
        return convertView;
    }
}
